package com.tourism.admin.controller.restful;


import com.tourism.admin.entity.Result;
import com.tourism.admin.service.ReportService;
import com.tourism.admin.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ReportController {

    @Autowired
    ReportService reportService;

    @PutMapping("/report/add/u")
    Result addReportU(@RequestParam("content") String content, @RequestParam("ouid") Integer ouid, @RequestParam("uid") Integer uid){
        return ResultUtil.success(reportService.addReportU(content,ouid,uid));
    }
    @PutMapping("/report/add/p")
    Result addReportP(@RequestParam("content") String content, @RequestParam("pid") Integer pid, @RequestParam("uid") Integer uid){
        return ResultUtil.success(reportService.addReportP(content,pid,uid));
    }
    @DeleteMapping("/report/delete")
    Result addReportU(@RequestParam("id") Integer id){
        return ResultUtil.success(reportService.deleteReport(id));
    }

    @GetMapping("/report/pid/{pid}")
    Result getReportPostUIDs(@PathVariable("pid") Integer pid){
        return ResultUtil.success(reportService.getReportPostUIDs(pid));
    }
    @GetMapping("/report/ouid/{ouid}")
    Result getReportUserUIDs(@PathVariable("ouid") Integer ouid){
        return ResultUtil.success(reportService.getReportUserUIDs(ouid));
    }
    @GetMapping("/report/user/status")
    Result getReportUserStatus(){
        Object object = reportService.getReportUserStatus();
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.success(null);
        }
    }
    @GetMapping("/report/post/status")
    Result getReportPostStatus(){
        Object object = reportService.getReportPostStatus();
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.success(null);
        }
    }
    @GetMapping("/report/user/sum")
    Result getReportUserSum(){
        Object object = reportService.getReportUserSum();
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.success(null);
        }
    }
    @GetMapping("/report/post/sum")
    Result getReportPostSum(){
        Object object = reportService.getReportPostSum();
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.success(null);
        }
    }

    @PostMapping(value = "/report/status/update")
    Result updateReportStatus(@RequestParam("id") Integer id){
        Object object = reportService.updateReportStatus(id);
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.success(null);
        }
    }

}
